<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
    <meta content="" name="description">
    <meta content="" name="author">
    <title>教务系统</title>
    <!-- Bootstrap core CSS -->
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <!-- Custom styles for this template -->
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">


</head>
<body>
<!--顶部导航栏-->
<div th:replace="~{student/common::topbar}"></div>

<div class="container-fluid">
    <div class="row">
        <!--侧边栏 组件化-->
        <div th:replace="~{student/common::sidebar(active='homePage.html')}"></div>
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h1 class="h3">个人信息</h1>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <button class="btn btn-sm btn-outline-secondary" id="btn-dormInfo">我的寝室</button>
                        <!-- <button id="btn-exam" class="btn btn-sm btn-outline-secondary">我的考试</button>-->
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-sm btn-outline-secondary" id="btn-apply">申请住校</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-quitDorm-apply">撤销申请</button>
                    </div>
                    <div class="btn-group mr-2">

                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">重新登陆</button>
                        <!-- <button id="btn-refresh" class="btn btn-sm btn-outline-secondary">刷新页面</button>-->
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-hover table-bordered table-striped table-sm">
                    <thead>
                    <tr>
                        <th>学号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>民族</th>
                        <th>入学时间</th>
                        <th>毕业时间</th>
                        <th>状态</th>
                        <th>班级</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td id="td" th:text="${session.student.getSno()}"></td>
                        <td th:text="${session.student.getSname()}"></td>
                        <td th:text="${session.student.getSex()}"></td>
                        <td th:text="${session.student.getNatice()}"></td>
                        <td th:text="${#dates.format(session.student.getEntrance(),'yyyy-MM-dd')}"></td>
                        <td th:text="${#dates.format(session.student.getGraduate(),'yyyy-MM-dd')}"></td>
                        <td th:text="${session.student.getGrade()==1?'在读':'休学'}"></td>
                        <td th:text="${session.student.getSclass()}"></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>

    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!--<script type="text/javascript" src="../../static/js/jquery-3.2.1.slim.min.js" th:src="@{/static/js/jquery-3.2.1.slim.min.js}"></script>-->
<script src="../../static/js/jquery-3.6.0.js" th:src="@{/static/js/jquery-3.6.0.js}"></script>
<!--<script type="text/javascript" src="../../static/js/popper.min.js" th:src="@{/static/js/popper.min.js}"></script>-->
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script src="../../static/js/btn.js" th:src="@{/static/js/btn.js}"></script>
<!-- Icons -->
<!--<script type="text/javascript" src="../../static/js/feather.min.js" th:src="@{/static/js/feather.min.js}"></script>-->
<!-- Graphs -->
<!--<script type="text/javascript" src="../../static/js/Chart.min.js" th:src="@{/static/js/Chart.min.js}"></script>-->
<script>
    let sno = [[${session.student.getSno()}]];
    let sname = '[[${session.student.getSname()}]]';
    let sex = '[[${session.student.getSex()}]]';
    $(function () {
        let dormInfo = $('#btn-dormInfo');
        let quitDorm = $("#btn-quitDorm-apply");
        let dormApply = $('#btn-apply');
        $.get({
            url: "/student/ajax/judgeStuDorm",
            data: {"sno": [[${session.student.getSno()}]]},
            success: function (result) {
                if (result === null) {
                    //alert("1")
                    dormApply.show();
                    dormInfo.hide();
                    quitDorm.hide();
                } else {
                    if (result.dorm_id !== null) {
                        // alert("2")
                        dormApply.hide();
                        dormInfo.show();
                        quitDorm.hide();
                    } else {
                        // alert('3')
                        dormApply.show();
                        dormInfo.hide();
                        quitDorm.show();
                    }
                }
            }
        })
        /*dormApply.click(function (){
            let sno = [[${session.student.getSno()}]];
            let sname = '[[${session.student.getSname()}]]';
            let sex = '[[${session.student.getSex()}]]';
                let judge = confirm("确定申请住校?");
                if (judge===true){
                    $.get({
                        url:"/student/ajax/getStuDorm",
                        data:{"sno":sno},
                        success:function (result){
                            if (result===true){
                                $.get({
                                    url: "/student/ajax/addStuDorm",
                                    data: {"sno":sno,"sname":sname,"sex":sex},
                                    success:function (value){
                                        if (value===true){
                                            alert("申请成功!");
                                        }else {
                                            alert("申请失败!请找管理人员");
                                        }
                                    }
                                })
                            }
                            else {
                                alert("你已经申请过了!请勿重复申请!");
                            }
                        }
                    })
                }else {

                }

        })*/
        /*quitDorm.click(function (){
            $.get({
                url:"/student/ajax/judgeStuDorm",
                data:{"sno":[[${session.student.getSno()}]]},
                success:function (result){
                    if (result===null){
                       alert("你未申请住校!无法撤销");
                    }
                    else{
                        if (result.dorm_id!==null){
                            let result = confirm("是否撤销你的住校申请!");
                            if (result===true){
                               alert("你无法撤销!")
                            }else {

                            }
                        }
                        else {
                            let result = confirm("是否撤销你的住校申请!");
                            if (result===true){
                                $.get({
                                    url:"/student/ajax/quitDormApply",
                                    data:{"sno":[[${session.student.getSno()}]]},
                                    success:function (result){
                                        if (result===true){
                                            alert("你已撤销!");
                                        }
                                        else {
                                            alert("撤销失败!没有你的申请记录!");
                                        }
                                    }
                                })
                            }else {

                            }
                        }
                    }
                }
            })
        })*/
        /* $('#btn-admin').click(function (){
             let result = confirm("是否进入管理员登录?");
             if (result===true){
               $(location).attr('href','/adminLogin.html');
             }else {

             }

         })*/
        /* dormInfo.click(function (){
             let sno=[[${session.student.getSno()}]];
             $(location).attr('href','/student/getStudentDormInfo/'+sno);
         })*/
        /* $('#btn-student').click(function (){
             let result = confirm("是否重新登录?");
             if (result===true){
                 $(location).attr('href','/studentLogin.html');
             }else {

             }
         })*/
        /*$('#btn-refresh').click(function (){
           // location.reload(true);
            let dormInfo = $('#btn-dormInfo');
            let quitDorm = $("#btn-quitDorm");
            let dormApply = $('#btn-dorm');
            $.get({
                url:"/student/ajax/judgeStuDorm",
                data:{"sno":[[${session.student.getSno()}]]},
                success:function (result){
                    if (result===null){
                        dormApply.show();
                        dormInfo.hide();
                        quitDorm.hide();
                    }
                    else{
                        if (result.dorm_id!==null){
                            dormApply.hide();
                            dormInfo.show();
                            quitDorm.show();
                        }
                        else {
                            dormApply.hide();
                            dormInfo.hide();
                            quitDorm.show();
                        }
                    }
                }
            })
        })*/
    })
</script>

</body>

</html>